<div id="box-thread">
    <div class="thread-name"><a class="back" href="<?php echo $this->url()->getUrl('view/forum/?id='.$this->thread['forum_id']) ?>" >Повернутись до списку тем</a><?php echo ($this->thread['title']); ?></div>
	<table class="thread" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
            <th class="mass-content">
            <?php $this->pager()->show($this->page, $this->totalPage, 10, $this->url()->getUrl('view/thread/?id='.$this->thread['id'])) ?>
            Повідомлення
            </th>
            <th class="mass-user">Користувач</th>
            </tr>
        </thead>
        <?php if(count($this->messages)){ ?>
		<tbody>
        <?php foreach($this->messages as $message){ ?>
            <tr>
            	
    			<td class="mass-content">
    				<p class="user"><span class="user" ><?php if(isset($this->users[$message['user_id']])){
    					echo $this->users[$message['user_id']]['username'];
    				}else{
    					echo "привидение :)";
    				} ?></span>&nbsp;&raquo;&nbsp;<span class="date"><?php echo $this->date()->format($message['created_on']); ?></span> </p>
					<?php if (trim($message['title']) != '') : ?> <h4><?php echo $message['title']; ?></h4> <?php endif; ?>
					<div class="mass" >
						<?php echo $message['content']; ?>
					</div>
    			</td>
    			<td class="mass-user"><?php if(isset($this->users[$message['user_id']])){
    					echo $this->users[$message['user_id']]['username']."<br/>";
						echo "Зарегистрирован:&nbsp;".$this->date()->format($this->users[$message['user_id']]['registered_on'])."<br/>";
    				}else{
    					echo "привидение :)";
    				} ?></td>
            </tr>		
        <?php }  ?>
        </tbody>
		<?php } ?>
	</table>
	<?php $this->pager()->show($this->page, $this->totalPage, 10, $this->url()->getUrl('view/thread/?id='.$this->thread['id'])) ?>
	<div>
		<input type="button" id="add_mass" value="Додати повідомлення" />
	</div>
    
    <form action="<?php echo $this->url()->getUrl('message/add/')?>" method="post">
	<table id="add" cellpadding="0" cellspacing="0" style="display: none;">
	    <thead>
            <tr>
            <th colspan="2">Нове повідомлення</th>
            </tr>
        </thead>	
        <tbody>	
			<tr>
				<td class="lable">
					Заголовок
				</td>
				<td>
					<input type="text" name="mass[title]" id="mass_title"/>
				</td>
			</tr>
			<tr>
				<td class="lable">
					Текст повідомлення
				</td>
				<td>
					<textarea name="mass[content]" id="mass_content" rows="6"></textarea>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>
					<input type="hidden" value="<?php echo ($this->thread['id']); ?>" name="mass[thread_id]" />
					<input type="submit" value="Додати"/>
					<input type="button" id="hideForm" value="Передумав"/>
				</td>
			</tr>
        </tbody>
	</table>
    </form>
</div>